﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Xml;
using Axis.Dao.Order;
using Axis.BusinessObject.Core;
using System.Web.Script.Serialization;
using Axis.Dao.Contact;

namespace Sotipha.Web.Views.Contact.Service
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    [System.Web.Script.Services.ScriptService]
    public class ContactService : System.Web.Services.WebService
    {
        [WebMethod(Description = "Per session Hit Counter", EnableSession = true)]
        public string SaveContact(string Name, string Phone, string Email, string Message)
        {
            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement("Root");
            XmlElement InputValue = doc.CreateElement("InputValue");
            root.AppendChild(InputValue);
            //InputValue.SetAttribute("UserID", CSecurity.USER_ID.ToString());
            //InputValue.SetAttribute("SecrectToken", CSecurity.SECRECT_TOKEN.ToString());
            InputValue.SetAttribute("Name", Name);
            InputValue.SetAttribute("Phone", Phone);
            InputValue.SetAttribute("Email", Email);
            InputValue.SetAttribute("Message", Message);
            InputValue.SetAttribute("Action", "INSERT");
           
            CContactDao orderDao = new CContactDao();
            CApplicationMessage message = orderDao.ActionContact(InputValue.OuterXml);
           
            string output = new JavaScriptSerializer().Serialize(message);
            return output;
        }
    }
}
